package com.elot.dto;

import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.springframework.stereotype.Component;

import com.elot.core.enums.RoleEnum;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@Component
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserDto {

	private Key id;
	
	private String user;
	private String password;
	private RoleEnum role;
	
	private String name;
	private String surname;
	private String address;
	private String cp;
	private String locality;
	private String province;
	private String country;
	
	private List<ReferenceDto> references;
	private List<BankAccountDto> favoriteBankAccount;
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	public Key getId() {
		return id;
	}
	public void setId(Key id) {
		this.id = id;
	}
	
	public UserDto() {
	}
	
	public UserDto(Long id, String user, String password, String name, String surname, String address, 
					String cp, String locality, String province, String country, List<ReferenceDto> references,
					List<BankAccountDto> favoriteBankAccount, RoleEnum role) {
	
		if (id!=null)
			this.id = new KeyFactory.Builder(this.getClass().getSimpleName(), id).getKey();
		this.user = user;
		this.password = password;
		this.name = name;
		this.surname = surname;
		this.address = address;
		this.cp = cp;
		this.locality = locality;
		this.province = province;
		this.country = country;
		this.references = references;
		this.favoriteBankAccount = favoriteBankAccount;
		this.role = role;

	}

	@Persistent
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	
	@Persistent
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	@Persistent
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Persistent
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}
	
	@Persistent
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	
	@Persistent
	public String getCp() {
		return cp;
	}
	public void setCp(String cp) {
		this.cp = cp;
	}
	
	@Persistent
	public String getLocality() {
		return locality;
	}
	public void setLocality(String locality) {
		this.locality = locality;
	}
	
	@Persistent
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	
	@Persistent
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	
	@Persistent
	public List<ReferenceDto> getReferences() {
		return references;
	}
	public void setReferences(List<ReferenceDto> references) {
		this.references = references;
	}
	
	@Persistent
	public List<BankAccountDto> getFavoriteBankAccount() {
		return favoriteBankAccount;
	}
	public void setFavoriteBankAccount(List<BankAccountDto> favoriteBankAccount) {
		this.favoriteBankAccount = favoriteBankAccount;
	}
	
	@Persistent
	public RoleEnum getRole() {
		return role;
	}
	public void setRole(RoleEnum role) {
		this.role = role;
	}
	
}
